<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport"
		content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

	<title>搜索页面</title>

	<link href="../AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css" />
	<link href="../AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css" />

	<link href="../basic/css/demo.css" rel="stylesheet" type="text/css" />

	<link href="../css/seastyle.css" rel="stylesheet" type="text/css" />

	<script type="text/javascript" src="../basic/js/jquery-1.7.min.js"></script>
	<script type="text/javascript" src="../js/script.js"></script>
	<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.6/vue.min.js"></script>
	<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.19.2/axios.min.js"></script>
	<script src="../js/axiosUtil.js"></script>
	<style>
		.goodImg {
			height: 218px;
			width: 218px;
		}
	</style>
</head>

<body>

	<div id="app1">
		<!--顶部导航条 -->
		<div class="am-container header">
			<ul class="message-l">
				<div class="topMessage">
					<template v-if="!islogin">
						<div class="menu-hd">
							<a href="login.html" target="_top" class="h">亲，请登录</a>
							<a href="register.html" target="_top">免费注册</a>
						</div>
					</template>
					<template v-else>
						<div class="menu-hd">
							<a href="#" style="color: red;">{{username}}</a>
							<a href="#" @click="logout">退出登录</a>
						</div>
					</template>
				</div>
			</ul>
			<ul class="message-r" v-if="islogin">
				<div class="topMessage home">
					<div class="menu-hd"><a href="home.html" target="_top" class="h">商城首页</a></div>
				</div>
				<template v-if="islogin">
					<div class="topMessage my-shangcheng">
						<div class="menu-hd MyShangcheng"><a href="information.html" target="_top"><i
									class="am-icon-user am-icon-fw"></i>个人中心</a></div>
					</div>
					<div class="topMessage mini-cart">
						<div class="menu-hd"><a id="mc-menu-hd" href="shopcart.html" target="_top"><i
									class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong
									id="J_MiniCartNum" class="h">0</strong></a></div>
					</div>
				</template>
			</ul>
		</div>

		<!--悬浮搜索框-->

		<div class="nav white">
			<div class="logo"><img src="../images/logo.png" /></div>
			<div class="logoBig">
				<li><img src="../images/logobig.png" /></li>
			</div>

			<div class="search-bar pr">
				<a name="index_none_header_sysc" href="#"></a>
				<form onsubmit="return false;">
					<input id="searchInput" name="index_none_header_sysc" type="text" placeholder="搜索"
						autocomplete="off" v-model="name">
					<input id="ai-topsearch" class="submit am-btn" value="搜索" index="1" type="button" @click="search">
				</form>
			</div>
		</div>

	</div>

	<div class="clear"></div>
	<b class="line"></b>
	<div class="search">
		<div class="search-list">
			<div class="nav-table">
				<div class="long-title"><span class="all-goods">全部分类</span></div>
				<div class="nav-cont">
					<ul>
						<li class="index"><a href="#">首页</a></li>
						<li class="qc"><a href="#">闪购</a></li>
						<li class="qc"><a href="#">限时抢</a></li>
						<li class="qc"><a href="#">团购</a></li>
						<li class="qc last"><a href="#">大包装</a></li>
					</ul>
				</div>

			</div>
			<ol class="am-breadcrumb am-breadcrumb-slash" style="margin-top: 10px;">
				<li><a href="home.html">首页</a></li>
				<li class="am-active">商品列表</li>
			</ol>


			<div class="am-g am-g-fixed">
				<div class="am-u-sm-12 am-u-md-12" id="app2">

					<div class="search-content">

						<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-4 boxes">
							<li v-for="(item,index) in tableData" :key="index">
								<div class="i-pic limit">
									<a href="#" @click="toGood(item.id)"><img :src="item.img" class="goodImg"/></a>
									<p class="title fl">{{item.name}}</p>
									<p class="price fl">
										<b>¥</b>
										<strong>{{item.price}}</strong>
									</p>
									<p class="number fl">
										库存<span>{{item.stock}}</span>
									</p>
								</div>
							</li>
						</ul>
					</div>

					<div class="clear"></div>
					<!--分页 -->
					<ul class="am-pagination am-pagination-right">
						<li :class="n==queryInfo.page?'am-active':''" v-for="n in pages">
							<a href="#" @click="next(n)">{{n}}</a>
						</li>
					</ul>

				</div>
			</div>

			<div class="footer">
				<div class="footer-hd ">
					<p>
						<a href="# ">燕园科技</a>
						<b>|</b>
						<a href="home.html">商城首页</a>
						<b>|</b>
						<a href="# ">支付宝</a>
						<b>|</b>
						<a href="# ">物流</a>
					</p>
				</div>
				<div class="footer-bd ">
					<p>
						<a href="#">关于燕园</a>
						<a href="# ">合作伙伴</a>
						<a href="# ">联系我们</a>
						<a href="# ">网站地图</a>
						<em>© 2020-2020 shop.ysu.edu 耿志龙 版权所有</em>
					</p>
				</div>
			</div>
		</div>

	</div>
	<script src="../js/public.js"></script>
	<script>
		var vm2 = new Vue({
			el: '#app2',
			data: {
				name: '',
				tableData: [],
				queryInfo: {
					name: '',
					page: 1
				},
				total: 0,
				pages: 1
			},
			created() {
				this.queryInfo.name = window.localStorage.getItem('goodName')||''
				this.getData()
			},
			methods: {
				getData() {
					$axios.get('/shop/goods/search',
						response => {
							this.tableData = response.data.records
							this.total = parseInt(response.data.total)
							this.pages = parseInt(response.data.pages)
						},
						this.queryInfo
					)
				},
				next(p) {
					if (p !== this.queryInfo.page) {
						this.queryInfo.page = p
						this.getData()
					}
				},
				toGood(id) {
					window.localStorage.setItem("goodId",id);
					window.location.href = 'introduction.html'
				}
			}
		})
	</script>
</body>

</html>